import java.util.ArrayList;

public class LoadedGestures extends LoadedSettings
{
	ArrayList<Gesture> gestures;
	static LoadedGestures rInstance;
	
	public ArrayList<Gesture> getGestures()
	{
		return gestures;
	}
	
	static public LoadedGestures getInstance()
	{
		if(rInstance == null)
		{
			rInstance = new LoadedGestures(defaultGesturesFilename);
		}
		return rInstance;
	}
	
	static public LoadedGestures getInstance(String file)
	{
		if(rInstance == null)
		{
			rInstance = new LoadedGestures(file);
		}
		return rInstance;
	}
	
	LoadedGestures(String file)
	{
		super(file);
		gestures = new ArrayList<Gesture>();
		loadGestures();
	}
	void loadGestures()
	{
		ArrayList<String> lines = load();
		for (String line : lines) 
		{
			String[] description = line.split(SPLITTER);
			/*
			 * description[0] == stringDescription
			 * description[1] == number from HashMap for modifier[0]
			 *	...
			 * description[n] == number from HashMap for modifier[n-1]
			 * 
			 * */
			ArrayList<Modifier> list = new ArrayList<Modifier>();
			for(int i=1;i<description.length;i++)
			{
				Modifier mod = LoadedModificators.getInstance().modifiers.get(Integer.parseInt(description[i]));
				if(mod ==null)
				{
					//TODO:throw Exception
				}
				list.add(mod);
			}
			gestures.add(new Gesture(
					description[0],
					list));
		}
		System.err.println("LOADED GESTURES\n========================================");
		for (Gesture gesture : gestures)
		{
			System.err.println(gesture.debug());
		}
	}
}